//  Created by zmyl on 2025/5/30.
//  Copyright © 2025 zmyl. All rights reserved.

/*
 ssk备注:
 网络框架使用NetworkManager工具类，也可以使用BaseRequest或GlobalRequest(之前的基于YTKNetwork，现在也不使用了)
 初始版本使用的是SJBaseRequest(不推荐使用这个)
*/

#import <Foundation/Foundation.h>
#import <MBProgressHUD.h>
#import "ResponseEntity.h"
#import <AFNetworking.h>

typedef enum : NSUInteger {
    RequestModule_Cheese = 1,
    RequestModule_Inquiry = 2,
    RequestModule_Simulation = 3,
    RequestModule_Anatomy = 4,
    RequestModule_Megagame = 5, // 大赛
} RequestModule;

typedef enum : NSUInteger {
    RequestMethodGET = 1,
    RequestMethodPOST = 2,
    RequestMethodPUT = 3,
    RequestMethodDELETE = 4,
} RequestMethod;

typedef enum : NSUInteger {
    TPHUDTypeIndicator = 1,
    TPHUDTypeCustom = 2,
} TPHUDType;

static const NSInteger AL_NETWORK_REQUEST_TIMEOUT = 60;


NS_ASSUME_NONNULL_BEGIN


@class RACSignal;

@protocol NetworkServiceProtocol <NSObject>

- (RACSignal *)rac_requestWithModule:(RequestModule)module
                              method:(RequestMethod)method
                              urlStr:(NSString *)urlStr
                          parameters:(nullable NSDictionary *)params
                         showLoading:(BOOL)showLoading
                             showTip:(BOOL)showTip;

// 可选添加基础方法
@optional
- (BOOL)isNetWorkAvailable;
- (void)cancelTasksForMethod:(RequestMethod)method url:(NSString *)url;

@end



@interface NetworkManager : NSObject <NSCopying, NSMutableCopying,NetworkServiceProtocol>

+ (instancetype)shared;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (id)copy NS_UNAVAILABLE; // 没有遵循协议可以不写
- (id)mutableCopy NS_UNAVAILABLE;

/// 是否有网络
- (BOOL)isNetWorkAvailable;

/// 检查有无网络
- (BOOL)checkNetWorkAvailable;

- (void)loadHttpRequest:(RequestModule)moduleType
                 method:(RequestMethod)method
                 urlStr:(NSString *)urlStr
             parameters:(nullable NSDictionary *)parameters
                success:(void (^)(ResponseEntity *responseModel))success
                failure:(void (^)(ResponseEntity *errModel))failure
            showLoading:(BOOL)showLoading
                showTip:(BOOL)showTip;

- (void)cancelNetworkRequest;

@end

NS_ASSUME_NONNULL_END
